Repository navigation
Review follow-ups: lead alert backlog, wrong numbers, listening lists and webhook - #5
Merged
Merged
Conversation
Twenty lists records by id, not by time. When more than 500 leads came in between two looks, a look read 500 of them in id order and marked seen up to the newest of those, past older leads it had never read. With no qualified lead among the 500, nothing was pushed for any of them. A look now reads every lead up to a time: when more came in than it reads, it closes the window at the median time of what it read, again until the window fits, and the next look carries on from there. Seen never passes a lead that wasn't read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
reachableOn dropped the phone whenever the dialer's latest call was a wrong or bad number, with no end and no look at which number was dialed: a prospect whose number was corrected in Twenty, or whose wrong number was logged two years ago, was never reachable by phone again. The phone now stays off only for 90 days (the window "not interested" already uses) and only while the prospect's phone is the number that was dialed, compared by its last ten digits. reachableOn takes the decision's clock. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
Save as a list named the file after the watch's name alone, so two watches with the same name wrote into one prospects-listen-<name>.csv and a campaign on it reached both watches' matches. The file is now named for the watch and its id, prospects-listen-<name>-<id>.csv; every watch together stays prospects-listen-all.csv. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
A delivery sent in chunks has no Content-Length, so the webhook read the whole body with request.text() before it compared it with the 2 MB limit: a large or endless body was held in memory first and refused only after. The body is now read a chunk at a time and the request is cancelled as soon as it passes the limit, in bytes rather than characters. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
ListenStore.receive wrote each match with its own awaited INSERT, so a 500-match digest made 500 round trips to the database inside one webhook request: on Vercel with Turso, enough to risk the function's time limit. Matches now go in one multi-row INSERT per hundred (seven values each, far under SQLite's limit), and ON CONFLICT still keeps each key once, a match repeated within one delivery included. The count of matches added is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
claimRun was added between metaValue's doc comment and metaValue, so claimRun carried two comments, the first describing metaValue, and metaValue had none. Each now sits above its own function. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
parseCalls copied the default days in one branch and returned a shallow copy that shared DEFAULT_CALL_HOURS.days in the other. That copy never left parseConfig (a calls: section that isn't a mapping fails the whole config), but both branches now go through one helper that copies the days, and a test checks a parsed config has its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TZhsuVXF5k9RXQpSdqYkdV
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rest of the review of #2, one commit each. #4 fixed the first two (opt-outs and one-line quiz answers).
What's in it
f38b686). Twenty lists records by id, not by time, so when more than 500 leads came in between two looks, a look read 500 in id order and marked seen up to the newest of those, past older leads it never read. With no qualified lead among the 500, none of them was pushed. A look now reads every lead up to a time: when more came in than it reads, the window closes at the median time of what it read until it fits, and the next look carries on from there.6d3e0ae). The phone stopped counting as a way to reach someone forever after one wrong-number call, even once their number was corrected in Twenty. It now stays off for 90 days (the window "not interested" already uses) and only while their phone is the number that was dialed, compared by its last ten digits.reachableOntakes the decision's clock.76a0ee7). Save as a list named the file after the watch's name alone, so two watches with the same name shared one list. It is nowprospects-listen-<name>-<id>.csv; every watch together staysprospects-listen-all.csv.8f68135). A delivery sent in chunks has no Content-Length, so the whole body was read before the 2 MB check. It is now read a chunk at a time and cancelled as soon as it passes the limit, in bytes.cefbb19). Each match was its own awaited INSERT: 500 round trips for a 500-match digest, inside one webhook request on Vercel and Turso. Now one multi-row INSERT per hundred; ON CONFLICT still keeps each key once, a repeat within one delivery included.744bf60).dab0abf). The shallow copy that sharedDEFAULT_CALL_HOURS.daysnever leftparseConfig(acalls:that isn't a mapping fails the whole config), so this changes no behaviour; both branches now copy through one helper.docs/decision-engine.mdand the CHANGELOG say what changed for wrong numbers, saved lists and lead alerts.How it was checked
bun run check: 397 tests pass (5 new), typecheck and the message lint clean.mainwithout its fix: a 1,200-lead backlog whose ids sort in another order than their times (each lead found exactly once across looks), a wrong number that is old or no longer theirs, two same-named watches saved as lists, a chunked delivery over the limit (refused after about 2 MB of a 6.5 MB body), and 250 matches kept in three statements.Generated by Claude Code